<template>
    <view>
        <!-- 实物商品 -->
        <view v-if="goodsDetail.productAttr != 2">
            <view class="pages">
                <view class="topbox" @tap="goshopingmall" v-if="!(goodsDetail.distributionType == 2 || storeid)">
                    <view>
                        <image src="/static/images/adds.png" class="topboxaddicon margin-right"></image>
                    </view>
                    <view class="toptextbox">
                        <view class="toptext">
                            <view class="text-black text-lg" style="margin-right: 20rpx">
                                {{ defaultAddress.name || '请选择收货地址' }}
                            </view>
                            <view class="text-black text-df">
                                {{ defaultAddress.phone }}
                            </view>
                        </view>
                        <view class="text-df text-darkGray margin-right-xs" style="width: 265px">
                            {{ defaultAddress.province }}{{ defaultAddress.city }}{{ defaultAddress.region }}{{ defaultAddress.detailAddress }}
                        </view>
                        <view class="text-red text-sm padding-tb-xs" v-if="feight.remark != null && goodsInfo.freightAomunt > 0">{{ feight.remark }}</view>
                    </view>
                    <image src="/static/images/righticon.png" class="toprighticon margin-right-xs"></image>
                </view>
            </view>

            <view class="pages">
                <view class="shoptexts">
                    <view class="shoptext">
                        <view>
                            <image :src="goodsInfo.mallSkuStockDto.pic" class="shopimg"></image>
                        </view>
                        <view class="margin-right margin-left">
                            <view class="text-black text-df">{{ goodsDetail.name }}</view>
                            <view class="text-darkGrey text-sm margin-top-xs">{{ spType }} | 数量:x{{ goodsInfo.mallSkuStockDto.quantity }}</view>
                            <view style="color: #ff1717" class="text-lg margin-top-xs">
                                <text v-if="checkMaker && goodsInfo.mallSkuStockDto.priceMaker">￥{{ goodsInfo.mallSkuStockDto.priceMaker }} +</text>
                                <block v-else>
                                    <text v-if="goodsInfo.mallSkuStockDto.price">￥{{ goodsInfo.mallSkuStockDto.price }} +</text>
                                </block>
                                <text>{{ goodsInfo.mallSkuStockDto.integration }}意豆</text>
                            </view>
                            <view v-if="activity" style="color: #ff1717" class="text-lg margin-top-xs">
                                <text>￥10.00 +</text>
                                <text>{{ currentObj.integration }}意豆</text>
                            </view>
                            <view v-if="activity" class="flexbox-sb activity-box mt-20">
                                <view class="text-black text-df">购买数量</view>
                                <view class="activity-centers">
                                    <view class="activity-lose" @tap="onLose">-</view>
                                    <view><input @input="bindinput" class="activity-input" type="number" :value="num" /></view>
                                    <view class="activity-add" @tap="onAdd">+</view>
                                </view>
                            </view>
                        </view>
                    </view>
                    <view class="storetext" v-if="storeid != undefined && storeid">
                        <view class="flexs align-center">
                            <image src="https://yiyueuser.oss-cn-shenzhen.aliyuncs.com/2022-02-15/92b0b6c61ee6472c9f0d4961963c57a5-file" class="storeimg"></image>
                            <view style="width: 500rpx">
                                <view>{{ storename }} {{ mobile }}</view>
                                <view>{{ path }}</view>
                            </view>
                        </view>
                        <view class="flexs align-center">
                            <view @tap="handDistributions">切换</view>
                            <image class="icon-32" src="https://kjyiyue.oss-cn-shenzhen.aliyuncs.com/images/right.png"></image>
                        </view>
                    </view>
                    <view class="storebtn" v-if="goodsDetail.distributionType == 3" @tap="handDistribution">{{ storeid ? '切换快递' : '选门店' }}</view>
                    <view :class="storeid ? 'storebtns' : 'storebtn'" v-if="goodsDetail.distributionType == 2" @tap="handDistribution">{{ storeid ? '已选' : '选门店' }}</view>
                </view>
                <view class="storealign margin-bottom-sm" v-if="goodsDetail.distributionType == 3">亲~可选择上门自提，下单后可出示核销码到门店提取</view>
                <view class="storealign margin-bottom-sm" v-if="goodsDetail.distributionType == 2">亲，此商品仅能上门自提，下单后可出示核销码到门店提货</view>
            </view>

            <view class="pages">
                <view class="margin-top-sm remarks bg-white">
                    <image src="/static/images/remarks.png" class="remarksimg margin-left-sm"></image>
                    <view class="text-darkGray text-df">订单备注：</view>
                    <input style="flex: 1; text-align: right" class="margin-right-sm text-df text-darkGrey" @input="onNote" placeholder="最多只能输入一百个字" maxlength="100" />
                </view>
            </view>
            <view class="pages">
                <view class="numbox margin-top-sm bg-white">
                    <view v-if="currentObj.price > 0">
                        <view class="numboxlist">
                            <view class="numboxlistleft">
                                <image src="/static/images/jine.png" class="numboximg margin-right-xs"></image>
                                <view class="text-df text-darkGray">商品金额:</view>
                            </view>
                            <view class="text-df text-darkGrey">¥{{ goodsInfo.productAmount }}</view>
                        </view>
                    </view>
                    <view v-if="!storeid">
                        <view class="numboxlist">
                            <view class="numboxlistleft">
                                <image src="/static/images/yunfei.png" class="numboximg margin-right-xs"></image>
                                <view class="text-df text-darkGray">运费金额:</view>
                            </view>
                            <view class="text-df text-darkGrey">¥{{ goodsInfo.freightAomunt || '0.00' }}</view>
                        </view>
                    </view>
                    <view>
                        <view class="numboxlist">
                            <view class="numboxlistleft">
                                <image src="/static/images/douzi.png" class="numboximg margin-right-xs"></image>
                                <view class="text-df text-darkGray">意豆:</view>
                            </view>
                            <view class="text-df text-darkGrey" style="color: #ff8722">{{ currentObj.integration }}</view>
                        </view>
                    </view>
                    <view class="numboxlist numsbottom" v-if="!storeid">
                        <view class="text-df text-black">应付金额:</view>
                        <view style="color: #ff1b0b">￥{{ goodsInfo.totalAmount || '0.00' }}</view>
                    </view>
                </view>
            </view>
        </view>
        <!-- 虚拟商品 -->
        <view class="pages" v-if="goodsDetail.productAttr == 2">
            <view class="shoptexts">
                <view class="shoptext">
                    <view>
                        <image :src="goodsInfo.mallProductDto.pic" class="shopimg"></image>
                    </view>
                    <view class="margin-right margin-left">
                        <view class="text-black text-df">{{ goodsDetail.name }}</view>
                        <view class="text-darkGrey text-sm margin-top-xs">数量:1</view>
                        <view style="color: #ff1717" class="text-lg margin-top-xs">
                            <text v-if="goodsInfo.totalAmount > 0">￥{{ goodsInfo.totalAmount }} +</text>
                            <text>{{ goodsInfo.integration }}意豆</text>
                        </view>
                    </view>
                </view>
                <view class="hrs"></view>
                <view class="user-msg-box">
                    <view class="user-msg">待充值账号信息</view>
                    <view class="user-type-box mt-20">
                        <view class="user-type">账号类型</view>
                        <view @tap="onType" data-index="2" :class="(nxType == 2 ? 'user-text-s' : 'user-text-x') + ' centers'">
                            <image :src="nxType == 2 ? imgUrl + 'xn-btns.png' : imgUrl + 'xn-btnx.png'" class="nx-icon margin-right-xs"></image>
                            <text>手机号码</text>
                        </view>
                        <view @tap="onType" data-index="1" :class="(nxType == 1 ? 'user-text-s' : 'user-text-x') + ' centers'">
                            <image :src="nxType == 1 ? imgUrl + 'xn-btns.png' : imgUrl + 'xn-btnx.png'" class="nx-icon margin-right-xs"></image>
                            <text>QQ号码</text>
                        </view>
                        <view @tap="onType" data-index="3" :class="(nxType == 3 ? 'user-text-s' : 'user-text-x') + ' centers'">
                            <image :src="nxType == 3 ? imgUrl + 'xn-btns.png' : imgUrl + 'xn-btnx.png'" class="nx-icon margin-right-xs"></image>
                            <text>其他</text>
                        </view>
                    </view>
                    <view class="user-account-box mt-20">
                        <view class="user-account">
                            <text>*</text>
                            <text>开通账号</text>
                        </view>
                        <input type="number" class="user-input" placeholder="请输入账号" @input="onInput" />
                    </view>
                </view>
                <view class="virtual-msg">
                    <view>温馨提示</view>
                    <view>1.此商品为虚拟商品，不支持七天无理由退换货，请谨慎购买；</view>
                    <view>2.虚拟商品，请仔细确认开通账号，一经开通无法变更账号；</view>
                    <view>3.如虚拟商品为卡密形式，可在已兑换的商品订单详情内查看。</view>
                </view>
            </view>
            <view class="pages">
                <view class="margin-top-sm remarks bg-white">
                    <image src="/static/images/remarks.png" class="remarksimg margin-left-sm"></image>
                    <view class="text-darkGray text-df">订单备注：</view>
                    <input style="flex: 1; text-align: right" class="margin-right-sm text-df text-darkGrey" @input="onNote" placeholder="最多只能输入一百个字" maxlength="100" />
                </view>
            </view>
            <view class="pages">
                <view class="numbox margin-top-sm bg-white">
                    <view v-if="currentObj.price > 0">
                        <view class="numboxlist">
                            <view class="numboxlistleft">
                                <image :src="imgUrl + 'xn-jine.png'" class="numboximg margin-right-xs"></image>
                                <view class="text-df text-darkGray">商品金额:</view>
                            </view>
                            <view class="text-df text-darkGrey">¥{{ goodsInfo.productAmount }}</view>
                        </view>
                    </view>
                    <view>
                        <view class="numboxlist">
                            <view class="numboxlistleft">
                                <image src="/static/images/douzi.png" class="numboximg margin-right-xs"></image>
                                <view class="text-df text-darkGray">意豆:</view>
                            </view>
                            <view class="text-df text-darkGrey" style="color: #ff8722">{{ goodsInfo.integration }}</view>
                        </view>
                    </view>
                    <view class="numboxlist numsbottom" v-if="!storeid">
                        <view class="text-df text-black">应付金额:</view>
                        <view style="color: #ff1b0b">￥{{ goodsInfo.totalAmount || '0.00' }}</view>
                    </view>
                </view>
            </view>
        </view>
        <view class="subbtn" @tap="sunfun">提交订单（{{ num }}）</view>
    </view>
</template>

<script>
// pagesb/confirmorder/confirmorder.js
const _request = require('../../utils/request.js');

const app = getApp();
export default {
    data() {
        return {
            imgUrl: app.globalData.imgUrl,

            //全局img路径
            num: 1,

            //总商品数
            currentObj: null,

            //选中的规格信息
            goodsDetail: null,

            //订单详情
            defaultAddress: {
                name: '',
                phone: '',
                province: '',
                city: '',
                region: '',
                detailAddress: ''
            },

            //选中地址
            remark: '',

            //备注
            activity: '',

            // 活动
            freight: 10,

            // 运费
            stock: 0,

            // 库存
            goodsInfo: {
                freightAomunt: 0,

                mallSkuStockDto: {
                    pic: '',
                    quantity: '',
                    priceMaker: '',
                    price: '',
                    integration: ''
                },

                productAmount: '',
                totalAmount: '',

                mallProductDto: {
                    pic: ''
                },

                integration: ''
            },

            spType: '',
            total: '',
            storeid: '',
            checkMaker: false,

            //是否是创客用户
            feight: {
                remark: ''
            },

            //运费设置
            nxType: 2,

            //账号类型
            account: '',

            // 充值账号
            currentsharer: '',

            distributionType: '',
            undefined: '',
            storename: '',
            mobile: '',
            path: ''
        };
    }
    /**
     * 生命周期函数--监听页面加载
     */,
    onLoad: function (options) {
        console.log(options);

        if (options.currentObj && options.currentObj != 'undefined') {
            let currentObj = JSON.parse(decodeURIComponent(options.currentObj));
            currentObj.price = (currentObj.price * options.num).toFixed(2);
            currentObj.integration = currentObj.integration * options.num;
            this.setData({
                currentObj: currentObj
            });
        }

        let goodsDetail = JSON.parse(decodeURIComponent(options.goodsDetail));
        console.log(goodsDetail);
        this.setData({
            num: options.num,
            goodsDetail: goodsDetail,
            currentsharer: options.sharer && options.sharer != 'undefined' ? options.sharer : ''
        });
    },
    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function () {},
    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {
        this.setData({
            checkMaker: uni.getStorageSync('maker')?.ismaker || false
        });
        this.query(); //获取地址
    },
    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function () {},
    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function () {},
    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function () {},
    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function () {},
    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function () {},
    methods: {
        // 选择虚拟商品类型
        onType(e) {
            this.setData({
                nxType: e.currentTarget.dataset.index
            });
        },

        // 充值账号
        onInput(e) {
            this.setData({
                account: e.detail.value
            });
        },

        // 加减操作
        onLose() {
            let vm = this;

            if (this.num == 1) {
                return;
            }

            this.setData(
                {
                    num: this.num - 1
                },
                () => {
                    vm.getMoney();
                }
            );
        },

        onAdd() {
            let vm = this;

            if (this.num == this.stock) {
                uni.showToast({
                    title: '购买数量不能大于库存',
                    icon: 'none'
                });
                this.setData({
                    num: this.stock
                });
                return;
            }

            this.setData(
                {
                    num: Number(this.num) + 1
                },
                () => {
                    vm.getMoney();
                }
            );
        },

        // 计算金额
        getMoney() {
            const { currentObj, num, freight } = this;
            let price = (10 * num).toFixed(2);
            console.log(price);
            let newcurrentObj = { ...currentObj, price };
            this.setData({
                freight: (10 * num).toFixed(2),
                currentObj: newcurrentObj
            });
        },

        bindinput(e) {
            let vm = this;

            if (e.detail.value >= this.stock) {
                uni.showToast({
                    title: '购买数量不能大于库存',
                    icon: 'none'
                });
                this.setData(
                    {
                        num: this.stock
                    },
                    () => {
                        vm.getMoney();
                    }
                );
                return;
            } else {
                this.setData(
                    {
                        num: Number(e.detail.value ? e.detail.value : 1)
                    },
                    () => {
                        vm.getMoney();
                    }
                );
            }
        },

        // 获取备注
        onNote(e) {
            this.setData({
                remark: e.detail.value
            });
        },

        goshopingmall() {
            uni.navigateTo({
                url: '/shopingmall/addressmanager/addressmanager?selected=1'
            });
        },

        sunfun() {
            //点击提交订单
            const { goodsDetail, goodsInfo, storeid, nxType, remark, account } = this;

            if (goodsDetail.productAttr != 2) {
                if (goodsDetail.distributionType != 2 && !storeid && !this.defaultAddress.id) {
                    uni.showToast({
                        title: '请先选择地址',
                        icon: 'none'
                    });
                    return;
                }

                if (goodsDetail.distributionType == 2 && !storeid) {
                    uni.showToast({
                        title: '请先选择自提门店',
                        icon: 'none'
                    });
                    return;
                }

                if (goodsInfo.totalAmount == 0) {
                    let that = this;
                    uni.showModal({
                        title: '温馨提示',
                        content: '需要扣除' + goodsInfo.mallSkuStockDto.integration + '意豆兑换，意豆兑换商品暂时不支持退换，请确认是否兑换！',
                        cancelText: '取消',
                        confirmText: '确认兑换',

                        success(res) {
                            if (res.confirm) {
                                that.submit();
                            } else if (res.cancel) {
                                console.log('用户点击取消');
                            }
                        }
                    });
                } else {
                    this.submit();
                }
            } else {
                if ((nxType == 2 && account.length != 11) || account.length == 0) {
                    uni.showToast({
                        title: '请输入正确充值账号',
                        icon: 'none'
                    });
                } else if (goodsInfo.totalAmount == '0.00' || goodsInfo.totalAmount == 0) {
                    let that = this;
                    uni.showModal({
                        title: '温馨提示',
                        content: '需要扣除' + goodsInfo.integration + '意豆兑换，意豆兑换商品暂时不支持退换，请确认是否兑换！',
                        cancelText: '取消',
                        confirmText: '确认兑换',

                        success(res) {
                            if (res.confirm) {
                                that.submitXn();
                            } else if (res.cancel) {
                                console.log('用户点击取消');
                            }
                        }
                    });
                } else {
                    this.submitXn();
                }
            }
        },

        //提交订单虚拟商品
        submitXn() {
            const { goodsDetail, goodsInfo, storeid, nxType, remark, account } = this;

            _request
                .postObj(
                    '/mall-order/virtual-submitOrder',
                    {
                        note: remark,
                        //备注
                        useIntegration: goodsInfo.integration,
                        //积分
                        rechargeType: nxType,
                        //充值类型 1-QQ号 2-手机号 3-其他
                        rechargeNumber: account,
                        //充值号码
                        sharer: this.currentsharer,
                        extendParameter: {
                            contactMobile: ''
                        },
                        //扩展参数
                        mallCartItemReq: {
                            productId: goodsInfo.mallProductDto.id,
                            //商品ID
                            quantity: 1,
                            //购买数量，必定为1
                            storeId: '',
                            productCategoryId: goodsInfo.mallProductDto.productCategoryId //商品分类ID
                        }
                    },
                    app.globalData.mallType
                )
                .then((res) => {
                    if (res.data.code == 200) {
                        if (goodsInfo.totalAmount == 0 || goodsInfo.totalAmount == '0.00') {
                            //纯意豆自提无需跳转支付
                            uni.showToast({
                                title: '兑换成功!',
                                icon: 'none'
                            });
                            setTimeout(() => {
                                uni.redirectTo({
                                    url: '/pages/mallorder/orderlist'
                                });
                            }, 1000);
                            return;
                        }

                        uni.navigateTo({
                            url:
                                '/pagesb/payment/payment?orderSn=' +
                                res.data.data.orderSn +
                                '&realityPayPrice=' +
                                res.data.data.realityPayPrice +
                                '&createordertime=' +
                                res.data.data.createOrderTime +
                                '&type=' +
                                res.data.data.type +
                                '&isLarge=' +
                                res.data.data.isLarge
                        });
                    } else {
                        uni.showToast({
                            title: res.data.message,
                            icon: 'none',
                            duration: 1500
                        });
                    }
                });
        },

        //提交订单
        submit() {
            const { defaultAddress, remark, num, currentObj, goodsDetail, goodsInfo, storeid } = this;

            _request
                .postObj(
                    '/mall-order/yd-submitOrder',
                    {
                        // userId: wx.getStorageSync('userId'),
                        addressId: storeid ? '' : defaultAddress.id,
                        note: remark,
                        useIntegration: goodsInfo.mallSkuStockDto.integration,
                        sharer: this.currentsharer,
                        mallCartItemReq: {
                            deleteStatus: 0,
                            distributionType: storeid ? 2 : 1,
                            goodsType: goodsDetail.goodsType,
                            isPurchase: 1,
                            price: goodsInfo.mallSkuStockDto.price,
                            productId: goodsDetail.id,
                            type: 1,
                            quantity: num,
                            memberId: 1,
                            //会员id 后端说写死不知道哪来的
                            productSkuCode: goodsInfo.mallSkuStockDto.skuCode,
                            productSkuId: currentObj.id,
                            productCategoryId: goodsDetail.productCategoryId,
                            userId: uni.getStorageSync('userId'),
                            specification: goodsInfo.mallSkuStockDto.specification,
                            storeId: storeid ? storeid : ''
                        }
                    },
                    app.globalData.mallType
                )
                .then((res) => {
                    if (res.data.code == 200) {
                        uni.setStorageSync('_shopmalladdress', '');

                        if (goodsInfo.totalAmount == 0 && (storeid || !res.data.data)) {
                            //纯意豆自提无需跳转支付
                            uni.showToast({
                                title: '兑换成功!',
                                icon: 'none'
                            });
                            setTimeout(() => {
                                uni.redirectTo({
                                    url: '/pages/mallorder/orderlist'
                                });
                            }, 1000);
                            return;
                        }

                        uni.navigateTo({
                            url:
                                '/pagesb/payment/payment?orderSn=' +
                                res.data.data.orderSn +
                                '&realityPayPrice=' +
                                res.data.data.realityPayPrice +
                                '&createordertime=' +
                                res.data.data.createOrderTime +
                                '&type=' +
                                res.data.data.type +
                                '&isLarge=' +
                                res.data.data.isLarge
                        });
                    } else {
                        uni.showToast({
                            title: res.data.message,
                            icon: 'none',
                            duration: 1500
                        });
                    }
                });
        },

        //运费设置
        feightFun() {
            _request
                .get(
                    '/mall-feight-template/getDetail',
                    {
                        addressId: this.defaultAddress.id || '',
                        type: this.goodsDetail.productType
                    },
                    app.globalData.mallType
                )
                .then((res) => {
                    if (res.data.code === 200) {
                        this.setData({
                            feight: res.data.data
                        });
                    }
                });
        },

        // 获取地址
        query() {
            _request
                .get(
                    '/mall-address/list',
                    {
                        // userId: wx.getStorageSync('userId'),
                        offset: 0
                    },
                    app.globalData.mallType
                )
                .then((res) => {
                    if (res.data.code === 200) {
                        let list = res.data.data || [];
                        var address = uni.getStorageSync('_shopmalladdress');

                        if (address) {
                            address = JSON.parse(address);
                            this.setData({
                                defaultAddress: address
                            });
                        } else {
                            let defaultAddress = list.filter((e) => e.status == 1);
                            console.log(defaultAddress, 'defaultAddress');

                            if (defaultAddress && defaultAddress.length) {
                                this.setData({
                                    defaultAddress: defaultAddress[0]
                                }); // wx.setStorageSync('_shopmalladdress', JSON.stringify(defaultAddress[0]))
                            }
                        } // if (this.data.defaultAddress) {

                        this.buy();
                        this.feightFun(); // } else if (list.length == 0) {
                        //   wx.showModal({
                        //     title: '您还未填写地址',
                        //     content: '请先填写收货地址',
                        //     success(res) {
                        //       if (res.confirm) {
                        //         wx.navigateTo({
                        //           url: '/shopingmall/addressmanager/addressmanager?selected=1',
                        //         })
                        //       } else if (res.cancel) {}
                        //     }
                        //   })
                        // }
                    }
                });
        },

        handDistribution(e) {
            if (!this.storeid) {
                uni.navigateTo({
                    url: '/shopingmall/stroemsg/stroemsg?productId=' + this.goodsDetail.id
                });
            } else {
                this.setData({
                    storeid: '',
                    distributionType: this.goodsDetail.distributionType
                });
                this.buy();
                this.feightFun();
            }
        },

        //切换
        handDistributions(e) {
            uni.navigateTo({
                url: '/shopingmall/stroemsg/stroemsg?productId=' + this.goodsDetail.id
            });
        },

        buy() {
            // 区分虚拟商品
            if (this.goodsDetail.productAttr != 2) {
                //获取商品详情
                _request
                    .get(
                        '/mall-cart-item/getBuyNow',
                        {
                            // userId: wx.getStorageSync('userId'),
                            quantity: this.num,
                            addressId: this.storeid ? '' : this.defaultAddress.id || '',
                            skuStockId: this.currentObj.id,
                            specification: JSON.stringify(this.currentObj.specification)
                        },
                        app.globalData.mallType
                    )
                    .then((res) => {
                        if (res.data.code == 200) {
                            let goodsInfo = res.data.data;
                            let spObj = JSON.parse(goodsInfo.mallSkuStockDto.specification);
                            let list = [];
                            spObj.forEach((item) => {
                                list.push(item.key + ':' + item.value);
                            });
                            let spType = list.join(',');
                            this.setData({
                                goodsInfo: goodsInfo,
                                spType: spType,
                                total: this.quantity
                            });
                        } else if (res.data.code === 500) {
                            uni.showToast({
                                title: res.data.data,
                                icon: 'none'
                            });
                        } else {
                            uni.showToast({
                                title: res.data.message,
                                icon: 'none'
                            });
                        }
                    })
                    .catch((error) => {
                        console.log(error, 'error');
                    });
            } else {
                _request
                    .get(
                        '/mall-cart-item/virtual/getBuyNow',
                        {
                            quantity: '1',
                            productId: this.goodsDetail.id
                        },
                        app.globalData.mallType
                    )
                    .then((res) => {
                        if (res.data.code == 200) {
                            let goodsInfo = res.data.data;
                            this.setData({
                                goodsInfo: goodsInfo,
                                total: this.quantity
                            });
                        } else if (res.data.code === 500) {
                            uni.showToast({
                                title: res.data.data,
                                icon: 'none'
                            });
                        } else {
                            uni.showToast({
                                title: res.data.message,
                                icon: 'none'
                            });
                        }
                    })
                    .catch((error) => {
                        console.log(error, 'error');
                    });
            }
        }
    }
};
</script>
<style>
page {
    background: #fbfbfb;
}

.pages {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    background-color: #fbfbfb;
}

.topbox {
    width: 710rpx;
    min-height: 180rpx;
    background: #fff;
    margin-top: 20rpx;
    display: flex;
    align-items: center;
    box-shadow: 2rpx 2rpx 8rpx 0rpx rgba(236, 236, 236, 0.4);
    border-radius: 12rpx;
}

.topboxaddicon {
    width: 80rpx;
    height: 80rpx;
    margin-left: 20rpx;
}

.toptext {
    display: flex;
    align-items: center;
}

.toprighticon {
    width: 32rpx;
    height: 32rpx;
    position: absolute;
    right: 20rpx;
}

.shoptexts {
    width: 710rpx;
    /* height: 240rpx; */
    background: #fff;
    margin-top: 20rpx;
    box-shadow: 2rpx 2rpx 8rpx 0rpx rgba(236, 236, 236, 0.4);
    border-radius: 12rpx;
}

.shoptext {
    align-items: center;
    display: flex;
}

.shopimg {
    width: 180rpx;
    height: 180rpx;
    margin: 0 30rpx;
}

.storetext {
    margin-top: 20rpx;
    margin-bottom: 10rpx;
    display: flex;
    justify-content: space-between;
    font-size: 28rpx;
    color: #666666;
}

.storeimg {
    width: 60rpx;
    height: 60rpx;
    margin: 0 30rpx;
}

.storebtn {
    width: 120rpx;
    height: 56rpx;
    background: #ff8722;
    color: #ffffff;
    font-size: 28rpx;
    line-height: 54rpx;
    text-align: center;
    border-radius: 44rpx;
    margin-right: 20rpx;
    float: right;
    margin-bottom: 20rpx;
}

.storebtns {
    width: 120rpx;
    height: 56rpx;
    background: #999999;
    color: #e7e7e7;
    font-size: 28rpx;
    line-height: 54rpx;
    text-align: center;
    border-radius: 44rpx;
    margin-right: 20rpx;
    float: right;
    margin-bottom: 20rpx;
}

.storealign {
    width: 710rpx;
    height: 38rpx;
    font-size: 24rpx;
    text-align: center;
    color: #ff8722;
    /* margin-bottom: 20rpx; */
    background: rgb(254, 245, 230);
    padding: 8rpx 0;
    border-radius: 0 0 8rpx 8rpx;
}

.remarks {
    width: 710rpx;
    height: 100rpx;
    box-shadow: 2rpx 2rpx 8rpx 0rpx rgba(236, 236, 236, 0.4);
    border-radius: 12rpx;
    align-items: center;
    display: flex;
}

.remarksimg {
    width: 32rpx;
    height: 32rpx;
    margin-right: 6rpx;
}

.numbox {
    width: 710rpx;
    /* height: 320rpx; */
    box-shadow: 2rpx 2rpx 8rpx 0rpx rgba(236, 236, 236, 0.4);
    border-radius: 12rpx;
    display: flex;
    flex-flow: column;
}

.numboximg {
    width: 32rpx;
    height: 32rpx;
}

.numboxlist {
    width: 670rpx;
    margin: 16rpx auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.numboxlistleft {
    display: flex;
    align-items: center;
}

.numsbottom {
    border-top: 1rpx solid #cacaca;
    padding: 20rpx 0;
    margin: 20rpx auto;
}

.subbtn {
    width: 670rpx;
    height: 88rpx;
    background: #ff8722;
    border-radius: 44rpx;
    margin: 100rpx auto 0;
    text-align: center;
    line-height: 88rpx;
    color: #fff;
    font-size: 32rpx;
}

.activity-box {
    width: 480rpx;
}

.activity-centers {
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    border: 1px solid #999;
    border-radius: 10rpx;
}

.activity-lose,
.activity-add {
    width: 50rpx;
    color: #999;
    font-size: 28rpx;
    font-weight: bold;
    text-align: center;
}

.activity-input {
    width: 100rpx;
    border-left: 1px solid #999;
    border-right: 1px solid #999;
    text-align: center;
}

/* 虚拟商品 */
.virtual-msg {
    height: 174rpx;
    font-size: 24rpx;
    font-family: PingFangSC-Medium, PingFang SC;
    font-weight: 500;
    color: #ff1717;
    line-height: 34rpx;
    margin: 20rpx;
}

.user-msg-box {
    padding: 20rpx;
}

.user-text-s {
    height: 40rpx;
    font-size: 28rpx;
    font-family: PingFangSC-Regular, PingFang SC;
    font-weight: 400;
    color: #ff8722;
    line-height: 40rpx;
}

.user-text-x {
    height: 40rpx;
    font-size: 28rpx;
    font-family: PingFangSC-Regular, PingFang SC;
    font-weight: 400;
    color: #999999;
    line-height: 40rpx;
}

.user-type {
    height: 40rpx;
    font-size: 28rpx;
    font-family: PingFangSC-Regular, PingFang SC;
    font-weight: 400;
    color: #333333;
    line-height: 40rpx;
}

.user-msg {
    height: 44rpx;
    font-size: 32rpx;
    font-family: PingFangSC-Medium, PingFang SC;
    font-weight: 500;
    color: #333333;
    line-height: 44rpx;
}

.nx-icon {
    width: 36rpx;
    height: 36rpx;
    margin-right: 5rpx;
}

.user-type-box {
    display: flex;
    flex-wrap: nowrap;
    justify-content: space-between;
    align-content: center;
    align-items: center;
}

.user-account-box {
    display: flex;
    flex-wrap: nowrap;
    justify-content: space-between;
    align-content: center;
    align-items: center;
}

.user-account > text:nth-child(1) {
    height: 40rpx;
    font-size: 28rpx;
    font-family: PingFangSC-Regular, PingFang SC;
    font-weight: 400;
    color: #ff0000;
    line-height: 40rpx;
}

.user-account > text:nth-child(2) {
    height: 40px;
    font-size: 28rpx;
    font-family: PingFangSC-Regular, PingFang SC;
    font-weight: 400;
    color: #333333;
    line-height: 40rpx;
}

.user-input {
    width: 524rpx;
    height: 76rpx;
    background: #f6f6f6;
    border-radius: 4rpx;
    padding-left: 20rpx;
    font-family: PingFangSC-Regular, PingFang SC;
    font-weight: 400;
    color: #999999;
}
</style>
